<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        {include file="public/static" /}
    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                      <div class="layui-form-item">
                          <label for="title" class="layui-form-label">
                              <span class="x-red">*</span>上级菜单
                          </label>
                          <input type="hidden" id="me_pid" name="me_pid" value="{$Request.param.pid}" />
                          <div class="layui-input-inline">
                              <input type="text" disabled value="{$parent}" lay-verify="required"
                              autocomplete="off" class="layui-input">
                          </div>
                      </div> 
                      <div class="layui-form-item">
                          <label for="title" class="layui-form-label">
                              <span class="x-red">*</span>菜单名
                          </label>
                          <div class="layui-input-inline">
                              <input type="text" id="me_name" name="me_name" value="" lay-verify="required"
                              autocomplete="off" class="layui-input">
                          </div>
                      </div> 
                      <div class="layui-form-item">
                          <label for="title" class="layui-form-label">
                              <span class="x-red">*</span>链接
                          </label>
                          <div class="layui-input-inline">
                              <input type="text" id="me_url" name="me_url" value="#" lay-verify="required"
                              autocomplete="off" class="layui-input">
                          </div>
                      </div>
                    <div class="layui-form-item">
                        <label for="name" class="layui-form-label">
                            <span class="x-red">*</span>状态
                        </label>
                        <div class="layui-input-inline">
                            <select name="me_status" id="me_status">
                                <option value="1" selected >启用</option>
                                <option value="0" >禁用</option>
                            </select>
                        </div>
                    </div>
                  <div class="layui-form-item">
                      <label for="L_repass" class="layui-form-label"></label>
                      <button class="layui-btn" lay-filter="add" lay-submit="">提交</button>
                  </div>
              </form>
            </div>
        </div>
        <script>
            layui.use(['form', 'layer'], function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;
                //自定义验证规则
                form.verify({
                    //名称
                    /*title: function(value) {
                        if (value.length < 1) {
                            return '分类名称不能为空';
                        }
                    }*/
                });
                //监听提交
                form.on('submit(add)', function(data) {
                    var index = layer.load();
                    //发异步，把数据提交给php
                    $.ajax({
                        type:"post",
                        url:"{:url('Menu/menuAdd')}",
                        data: data.field,
                        dataType: 'json',
                        success:function (data) {
                            if(data.status === 1){
                                layer.msg(data.info, {icon: 6,time:1500}, function() {
                                    /*关闭弹出层并刷新*/
                                    common.closeWindowReload();
                                });
                            }else{
                                layer.msg(data.info, {icon: 5,time:1500});
                            }
                            layer.close(index);

                        },
                        error:function (data) {
                            console.log(data);
                            layer.msg("不好意思，出现了一点问题", {icon: 5});
                        }
                    });
                    //必须加上return false，不然无法关闭iframe
                    return false;
                });
            });
        </script>
    </body>
</html>
